package zilla.useraccounts;

import java.io.File;
import java.util.HashMap;

import zilla.filesystem.DirectoryTree;

public class UserAccount {

	String fName; 
	String lName;
	String username;
	String passwordHash;
	HashMap<AccountType, CloudAccount> accounts;
	DirectoryTree tree;
	Metadata data;
	
	
	public UserAccount()
	{
		accounts = new HashMap<AccountType, CloudAccount>();
		tree = new DirectoryTree();
	}
	
	public CloudAccount chooseAccount(File file)
	{
		long freeSpace = 0;
		CloudAccount chosenAccount = null;
		for(AccountType type: accounts.keySet())
		{
			CloudAccount account = accounts.get(type);
			Metadata accMeta = account.getMetaData();
			if(freeSpace < accMeta.freeSpace)
			{
				freeSpace = accMeta.freeSpace;
				chosenAccount = account;
			}
			
		}
		Metadata accMeta = chosenAccount.getMetaData();
		if(accMeta.freeSpace < file.length())
		{
			chosenAccount = null;
		}
		
		return chosenAccount;
	}
	
	public CloudAccount getCloudAccount(AccountType type){
		return accounts.get(type);
	}
	
	
}



